<template>
  <div class="category-percent">
    <div class="category-percent-content">
      <div class="category-percent-content-title">分类占比</div>
      <div class="category-percent-content-echarts">
        <screen-chart @initCb="initChart"></screen-chart>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import { getPercentChartOption } from './option'
@Component({
  name: 'category-percent'
})
export default class CategoryPercent extends Vue {
  private percentChart: any = null

  private percentList: any = [
    {
      name: '易燃',
      value: 0
    },
    {
      name: '易爆',
      value: 0
    },
    {
      name: '传染性',
      value: 0
    },
    {
      name: '腐蚀性',
      value: 0
    },
    {
      name: '有毒',
      value: 0
    },
    {
      name: '其他',
      value: 0
    }
  ]

  private initChart(chart: any): void {
    chart.clear()
    this.percentChart = chart
    setTimeout(() => {
      this.percentChart.setOption(
        getPercentChartOption({
          data: this.percentList
        })
      )
    }, 300)
  }
}
</script>

<style lang="scss" scoped>
.category-percent {
  box-sizing: border-box;
  width: 100%;
  // height: 40.2%;
  height: 40%;
  .category-percent-content {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    &-title {
      width: 100%;
      height: 30px;
      line-height: 30px;
      font-size: 18px;
      font-family: 'PingFang Regular';
      font-weight: 500;
      color: #ffffff;
      position: relative;
      padding-left: 33px;
      text-align: left;
    }
    &-title::after {
      content: '';
      display: block;
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: #23fffc;
      position: absolute;
      left: 18px;
      top: 10px;
    }
    &-echarts {
      width: 100%;
      height: calc(100% - 30px);
      // border: 1px solid red;
    }
  }
}
</style>
